<?php
namespace App\Controller;

class UserGroupsController extends AppController{

    public $_page_num = 30;
    public function initialize()
    {
        parent::initialize();
    }

    /*
    * create by phpstorm
    * author：Ming
    * date：2020.06.30
    * ps：设置用户组
    * */
    public function setUserGroup()
    {
        $data = $this->request->getData();
        $this->loadModel('UserGroups');
        $this->UserGroups->query()
            ->update()
            ->set(['user_aro_id'=>$data['user_aro_id'],'begin_time'=>strtotime($data['begin_time']),'end_time'=>strtotime($data['end_time'])])
            ->where(['user_id in' => $data['user_ids']])
            ->execute();
        $this->loadComponent('UserCache');
        foreach ($data['user_ids'] as $k=>$v){
            $this->UserCache->deleteUserCache($v);
        }
        $this->UserCache->deleteCache();
        $this->G->success('Success');
    }

}
?>